package main.flex.value.calendar
{
	import main.flex.conf.CalendarConf;
	import main.flex.value.UserVO;
	
	import org.servebox.foundry.value.AbstractValueObject;

	[RemoteClass(alias="value.calendar.CalendarGuestVO")]
	public class CalendarGuestVO extends AbstractValueObject
	{	
		private var _id 						: int;
		private var _event_id 					: int;
		private var _user_id 					: UserVO;
		private var _response					: String;
		
		public function CalendarGuestVO ( 
											pId			: int,
											pEventId	: int,
											pUserId 	: UserVO = null,
											pResponse = CalendarConf.AWAITING_RESPONSE_STATUS )
		{
			id 			= pId;
			event_id 	= pEventId;
			response	= pResponse;
			
			if ( pUserId )
				user_id 	= pUserId;
		}
		
		/* -------------------------------------------------------------------------- */
		/* GETTER & SETTER */
		/* -------------------------------------------------------------------------- */
		
		/**
		 * @return the id
		 */
		public function get id() : int
		{
			 return _id;
		}
		public function set id( value : int ) : void
		{
			_id = value;
		}
		
		/**
		 * @return the event_id
		 */
		public function get event_id() : int
		{
			 return _event_id;
		}
		public function set event_id( value : int ) : void
		{
			_event_id = value;
		}
		
		public function get user_id ( ) : UserVO
		{
			return _user_id;
		}
		
		public function set user_id ( val : UserVO ) : void
		{
			_user_id = val;
		}
		
		public function get response ( ) : String
		{
			return _response;
		}
		
		public function set response ( val : String ) : void
		{
			var lng : uint = CalendarConf.AVAILABLE_RESPONSE_STATUS.length;
			
			for ( var i : uint = 0 ; i < lng ; i++ )
			{
				if ( val != CalendarConf.AVAILABLE_RESPONSE_STATUS[ i ] )
					continue;
				else
				{
					_response = val;
					return; // empeche le declenchemet de l'erreur
				}
			}
			
			throw new Error("Vous devez spécifier une réponse valide à l'invitation faite à l'utilisateur");
		}
	}
}